<extend name="Public/base" />

<block name="body">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title cf">
        <h2>新增 [{$model['title']}]</h2>
    </div>
    <!-- 标签页导航 -->
<div class="tab-wrap">
    <ul class="tab-nav nav">
        <li data-tab="tab1" class="current"><a href="javascript:void(0);">基础</a></li></li>
    </ul>
    <div class="tab-content zc_for">
    <!-- 表单 -->
    <form id="form" action="{:U('edit?id='.$data['id'])}" method="post" class="form-horizontal">
        <!-- 基础文档模型 -->
        <div id="tab1" class="tab-pane in tab1">
            <table  border="0" cellspacing="0" cellpadding="0">
                <tbody>
                <tr>
                    <td class="l">所属后台：</td>
                    <td class="r">
                        <select name="mark" id="mark">
                            <option value="0" <if condition="($data['mark'] eq 0)"> selected = "selected"</if>>媒体官网</option>
                            <option value="1"<if condition="($data['mark'] eq 1)"> selected = "selected"</if>>渠道站</option>
                        </select>
                    </td>
                </tr>
                  <tr>
                    <td class="l">友链标题：</td>
                    <td class="r">
                       <input type="text" name='title' style="width:333px" value='{$data.title}'>
                    </td>
                    </tr>
                    <tr>
                    <td class="l">友链URL：</td>
                    <td class="r">
                       <input type="text" name='link_url' style="width:333px" value='{$data.link_url}'>
                    </td>
                    </tr>
                    <tr>
                    <td class="l">友链状态：</td>
                    <td class="r">
                        <label class="inp_radio">
                            <input type="radio" class="inp_radio" value="0" name="status" <eq name="data['status']" value="0">checked="checked"</eq>>关闭
                            <input type="radio" class="inp_radio" value="1" name="status" <eq name="data['status']" value="1">checked="checked"</eq>>开启
                        </label>
                    </td>
                    </tr>
                    <tr>
                    <td class="l">友链类型：</td>
                    <td class="r">
                      <select name="type" value=''>
                        <option value="" selected="">请选友链类型</option>
                        <option value="1" <eq name="data['type']" value="1">selected = "selected"</eq>>111</option>
                        <option value="2" <eq name="data['type']" value="2">selected = "selected"</eq>>222</option>
                        <option value="3" <eq name="data['type']" value="3">selected = "selected"</eq>>333</option>
                        <option value="4" <eq name="data['type']" value="4">selected = "selected"</eq>>444</option>
                       </select>
                    </td>
                    </tr>
                    <tr>
                    <td class="l">友链备注：</td>
                    <td class="r" colspan='3'>
                        <textarea name="remark" class="txt_area1" >{$data.remark}</textarea>
                    </td>
                    </tr>
                    <!-- <input type="hidden" name='op_id' value='{:UID}'>
                    <input type="hidden" name='op_nickname' value='{:UID}'>
                    <input type="hidden" name='create_time' value='{:UID}'> -->
                </tbody>
            </table>
        </div>
        <div class="form-item cf">
            <button class="btn submit-btn ajax-post hidden" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <a class="btn btn-return" href="javascript:history.back(-1);">返 回</a>
        </div>
    </form>
    </div>
</div>
</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('Links/lists')}');
$('#submit').click(function(){
    $('#form').submit();
});

$(function(){
    $("#game_name").val($("#game_id option:selected").text());
    
    $('.date').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });
    $('.time').datetimepicker({
    language:"zh-CN",
     hour: 13,
       minute: 15
    });
    showTab();
    
});

/*获取游戏名称*/
$("#game_id").change(function() {
    $("#game_name").val($("#game_id option:selected").text());
});

/*获取区服名称*/
$("#server_id").change(function() {
    $("#server_name").val($("#server_id option:selected").text());
});
var url = "{:U('Giftbag/get_ajax_area_list')}";
$("#game_id").change(function(){
    fun_ajax($(this).val());
})

function fun_ajax(gid){
    $.ajax({
        type:"post",
        url:url,
        dataType:"json",
        data:{game_id:gid},
        success:function(data){
            fun_html(data);
            $("#server_name").val($("#server_id option:selected").text());
        },
        error:function(){
            layer.msg('服务器异常',{icon:5});
        }
    })
}



function fun_html(data){
    var area='';
    if(data == null){
        $("#area_id").html('<option value="">请选择区服</option>');
    }else{
        for (var i = 0; i<data.length; i++){
            area+='<option value="'+data[i]['id']+'">'+data[i]['server_name']+'</option>';
        }
        $("#server_id").html(area);
    }
}
</script>
</block>